Skip to content

gh-146609: Add colour to timeit CLI output#146610

Merged
hugovk merged 9 commits intopython:mainfrom
hugovk:3.15-timeit-colour
Apr 8, 2026
Merged

gh-146609: Add colour to timeit CLI output#146610
hugovk merged 9 commits intopython:mainfrom
hugovk:3.15-timeit-colour

Conversation

@hugovk
Copy link
Copy Markdown
Member

@hugovk hugovk commented Mar 29, 2026

Standard and verbose:

./python.exe -m timeit "'-'.join(str(n) for n in range(100))"
./python.exe -m timeit --verbose "'-'.join(str(n) for n in range(100))"
image

With a warning:

./python.exe -m timeit "import time, random; time.sleep(random.random() * 0.9)"
image

As usual, environment variables can control colour output.


📚 Documentation preview 📚: https://cpython-previews--146610.org.readthedocs.build/

@ambv
Copy link
Copy Markdown
Contributor

ambv commented Apr 7, 2026

Nitpick: I would segment this differently. The fact that the entire line after "raw times:" is just cyan is a wasted opportunity. Would make sense to me to make the commas delimiting the values be colored the same way as the arrows.

@hugovk
Copy link
Copy Markdown
Member Author

hugovk commented Apr 7, 2026

Like this?

image

@ambv
Copy link
Copy Markdown
Contributor

ambv commented Apr 8, 2026

Yes, that looks better to me!

@hugovk hugovk merged commit 8687b9d into python:main Apr 8, 2026
60 checks passed
@hugovk hugovk deleted the 3.15-timeit-colour branch April 8, 2026 13:18
@hugovk
Copy link
Copy Markdown
Member Author

hugovk commented Apr 8, 2026

Thanks both for the reviews!

@bedevere-bot

This comment was marked as off-topic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants